<!-- Graficas -->
<script type="text/javascript" src="<?= base_url() ?>assets/amcharts/amcharts.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/amcharts/serial.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/amcharts/pie.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/amcharts/themes/dark.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/amcharts/themes/none.js"></script>

<style type="text/css">
    #chart-rendimiento-empresas {
        color:#ffffff;
        width: 100%;
        height: 400px;
        font-size: 11px;
    }
    #chart-rendimiento-divisiones {
        color:#ffffff;
        height: 400px;
        font-size: 11px;
    }

    #chart-personas-empresa {
        color:#ffffff;
        height: 400px;
        font-size: 11px;
    }
     #chartdivexame {
        color:#ffffff;
        height: 400px;
        font-size: 11px;
    }

</style>
<script>
            var chart = AmCharts.makeChart("chart-rendimiento-empresas", {
            "type": "serial",
                    "theme": "none",
                    "pathToImages": "<?= base_url() ?>assets/amcharts/images/",
                    "dataProvider": [
<?php foreach ($empresa_cal as $v) { ?>
                        {
                        "empresa": "<?= $v->e_nombre ?>",
                                "porm": <?= $v->prom ?>,
                                "color": "<?php echo $color = randomColor(); ?>"
                        },
<?php } ?>
                    ],
                    "valueAxes": [{
                    "axisAlpha": 0,
                            "position": "left",
                            "title": "Promedio por empresa"
                    }],
                    "startDuration": 1,
                    "graphs": [{
                    "balloonText": "<b>[[category]]: [[value]]</b>",
                            "fillColorsField": "color",
                            "fillAlphas": 0.9,
                            "lineAlpha": 0.2,
                            "type": "column",
                            "valueField": "porm"
                    }],
                    "chartCursor": {
                    "categoryBalloonEnabled": false,
                            "cursorAlpha": 0,
                            "zoomable": false
                    },
                    "categoryField": "empresa",
                    "categoryAxis": {
                    "gridPosition": "start",
                            "labelRotation": 45
                    },
                    "amExport": {}

            });</script>
<script>
            var chart = AmCharts.makeChart("chart-rendimiento-divisiones", {
            "type": "serial",
                    "theme": "none",
                    "handDrawn": true,
                    "handDrawScatter": 3,
                    "legend": {
                    "useGraphSettings": true,
                            "markerSize": 12,
                            "valueWidth": 0,
                            "verticalGap": 0
                    },
                    "dataProvider": [
<?php foreach ($division_cal as $d) { ?>
                        {
                        "division": "<?= $d->d_nombre ?>",
                                "income": <?= $d->prom ?>,
                                "expenses": 18.1
                        },
<?php } ?>
                    ],
                    "valueAxes": [{
                    "minorGridAlpha": 0.08,
                            "minorGridEnabled": true,
                            "position": "top",
                            "axisAlpha": 0
                    }],
                    "startDuration": 1,
                    "graphs": [{
                    "balloonText": "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b></span>",
                            "title": "Divisiones",
                            "type": "column",
                            "fillAlphas": 0.8,
                            "valueField": "income"
                    }],
                    "rotate": true,
                    "categoryField": "division",
                    "categoryAxis": {
                    "gridPosition": "start"
                    }
            });</script>

<script>
            var chart = AmCharts.makeChart("chart-personas-empresa", {
            "type": "serial",
                    "theme": "none",
                    "handDrawn": true,
                    "handDrawScatter": 3,
                    "legend": {
                    "useGraphSettings": true,
                            "markerSize": 12,
                            "valueWidth": 0,
                            "verticalGap": 0
                    },
                    "dataProvider": [
<?php foreach ($tpersonasXE as $t) { ?>
                        {
                        "year": "<?= $t->e_nombre ?>",
                        "income": <?= $t->tpersonas ?>
                        },
<?php } ?>
                    ],
                    "valueAxes": [{
                    "minorGridAlpha": 0.08,
                            "minorGridEnabled": true,
                            "position": "top",
                            "axisAlpha": 0
                    }],
                    "startDuration": 1,
                    "graphs": [{
                    "balloonText": "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b></span>",
                            "title": "Empleados",
                            "type": "column",
                            "fillAlphas": 0.8,
                            "valueField": "income"
                    }],
                    "rotate": true,
                    "categoryField": "year",
                    "categoryAxis": {
                    "gridPosition": "start"
                    }
            });
</script>
<script type="text/javascript">
    var chart = AmCharts.makeChart("chartdivexame", {
        "theme": "none",
        "type": "serial",
        "dataProvider": [
<?php foreach ($graphComp as $v) { ?>
                {
                    "empresa": "<?= $v->e_nombre ?>",
                    "extot": <?= $v->totalTest ?>,
                    "exreal": <?= $v->nTestDone ?>
                },
<?php } ?>
        ],
        "valueAxes": [{
                "unit": "",
                "position": "left",
                "title": "Número",
            }],
        "startDuration": 1,
        "graphs": [{
                "balloonText": "Numero de examens totales [[category]]: <b>[[value]]</b>",
                "fillAlphas": 0.9,
                "lineAlpha": 0.2,
                "title": "2004",
                "type": "column",
                "valueField": "extot"
            }, {
                "balloonText": "Numero de examens realizados [[category]]: <b>[[value]]</b>",
                "fillAlphas": 0.9,
                "lineAlpha": 0.2,
                "title": "2005",
                "type": "column",
                "clustered": false,
                "columnWidth": 0.5,
                "valueField": "exreal"
            }],
        "plotAreaFillAlphas": 0.1,
        "categoryField": "empresa",
        "categoryAxis": {
            "gridPosition": "start"
        }
    });
</script>

<!-- Content -->
<div id="content">

    <!-- Content wrapper -->
    <div class="wrapper">

        <!-- Breadcrumbs line -->
        <div class="crumbs">
            <ul id="breadcrumbs" class="breadcrumb"> 
                <li><a href="<?= base_url('xpanel') ?>">XPANEL</a></li>
                <li class="active"><a href="<?= base_url() ?>" title="">Inicio</a></li>
            </ul>

        </div>
        <!-- /breadcrumbs line -->

        <!-- Page header -->
        <div class="page-header">
            <div class="page-title">
                <h5>XPANEL</h5>
            </div>

        </div>
        <!-- /page header -->

        <!-- Full size widget -->
        <div class="widget">
            <div class="navbar"><div class="navbar-inner"><h6>Promedio por divisiones</h6></div></div>
            <div class="well body">
                <div id="chart-rendimiento-divisiones" ></div>   
            </div>
        </div>
        <!-- /full size widget -->

        <!-- Full size widget -->
        <div class="widget">
            <div class="navbar"><div class="navbar-inner"><h6>Empleados por divisiones</h6></div></div>
            <div class="well body">
                <div id="chart-personas-empresa" ></div>   
            </div>
        </div>
        <!-- /full size widget -->

        <!-- Grid widgets -->
        <div class="row-fluid">
            <div class="span6">
                <div class="widget">
                    <div class="navbar"><div class="navbar-inner"><h6>Promedio por empresa</h6></div></div>
                    <div class="well body">
                        <div id="chart-rendimiento-empresas"></div>
                    </div>
                </div>
            </div>
            <div class="span6">
                <div class="widget">
                    <div class="navbar"><div class="navbar-inner"><h6>Evaluaciónes</h6></div></div>
                    <div class="well body">
                        <div id="chartdivexame"></div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /grid widgets -->


        <!-- /content wrapper -->

    </div>
    <!-- /content -->
</div>
<!-- /content container -->

<?php

function randomColor() {
    $str = '#';
    for ($i = 0; $i < 6; $i++) {
        $randNum = rand(0, 15);
        switch ($randNum) {
            case 10: $randNum = 'A';
                break;
            case 11: $randNum = 'B';
                break;
            case 12: $randNum = 'C';
                break;
            case 13: $randNum = 'D';
                break;
            case 14: $randNum = 'E';
                break;
            case 15: $randNum = 'F';
                break;
        }
        $str .= $randNum;
    }
    return $str;
}
?>